package com.uobgroup.ews.uam.core.domain;

import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

import org.springframework.beans.factory.annotation.Configurable;

@Entity
@Configurable
@NamedQueries({
      @NamedQuery(name = "AccessControl.findByLikeName", query = "SELECT a FROM AccessControl a WHERE LOWER(a.name) LIKE :name"),
      @NamedQuery(name = "AccessControl.findByIDs", query = "SELECT a FROM AccessControl a WHERE a.id IN (:ids)") })
public class AccessControl extends BaseEntity {

   public static final String FINDBYLIKENAME = "AccessControl.findByLikeName";

   public static final String FINDBYIDs = "AccessControl.findByIDs";

   public static final String PARA_NAME = "name";

   public static final String PARA_IDs = "ids";

   @NotNull
   @Size(max = 255)
   private String name;

   private Integer permission;

   @Size(max = 1000)
   private String description;

   @Enumerated
   private CombinationType type;

   @Id
   @GeneratedValue(strategy = GenerationType.AUTO)
   @Column(name = "id")
   private Long id;

   @OneToMany(mappedBy = "accessControl")
   private List<CombinationACL> combinations;

   public Long getId() {
      return this.id;
   }

   public void setId(Long id) {
      this.id = id;
   }

   public String getName() {
      return this.name;
   }

   public void setName(String name) {
      this.name = name;
   }

   public Integer getPermission() {
      return this.permission;
   }

   public void setPermission(Integer permission) {
      this.permission = permission;
   }

   public String getDescription() {
      return this.description;
   }

   public void setDescription(String description) {
      this.description = description;
   }

   public List<CombinationACL> getCombinations() {
      return combinations;
   }

   public void setCombinations(List<CombinationACL> combinationACLs) {
      this.combinations = combinationACLs;
   }

   public CombinationType getType() {
      return type;
   }

   public void setType(CombinationType type) {
      this.type = type;
   }
}
